import Taro from "@tarojs/taro";
import {asyncTimeoutUtil} from "@/utils/utils";

export const getLoginCode = (timeout = 10 * 1000) => {
  const loginCodePromise = new Promise((resolve, reject) => {
    Taro.login({
      success: res => {
        if (res.code) {
          resolve(res.code)
        }
        reject("获取code失败");
      },
      fail: err => {
        reject(err)
      }
    })
  })
  return asyncTimeoutUtil(timeout, loginCodePromise);
}


